package com.wang.controller;

import com.aaa.entity.TbBanner;
import com.aaa.entity.TbBottomArticle;
import com.aaa.entity.TbLink;
import com.aaa.entity.TbZone;
import com.aaa.vo.Result;
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.baomidou.mybatisplus.extension.conditions.query.LambdaQueryChainWrapper;
import com.wang.service.*;
import com.wang.feigen.GoodsFeigen;
import com.wang.service.PageContextService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.CrossOrigin;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.util.List;

/**
 * @author :  DongZheng Wang
 * @PROJECT_NAME: fifth-cai-parent
 * @date :  2023-03-02 16:06
 **/

@RestController
@RequestMapping("/home")
public class TbBannerMapperController {
    @Autowired
    private TbBannerService tbBannerService;
    @Autowired
    private TbZoneService tbZoneService;
    @Autowired
    private GoodsFeigen goodsFeigen;
    @Autowired
    private TbBottomArticleService TbBottomArticleService;
    @Autowired
    private TbLinkService tbLinkService;
    @RequestMapping("/banner/rotationalSeeding")
    public Result TbBannerMapperResult() {
        LambdaQueryWrapper<TbBanner> wrapper = new LambdaQueryWrapper();
        wrapper.orderByDesc(TbBanner::getId);
        List<TbBanner> list = tbBannerService.list(wrapper);
        System.out.println("list = " + list);
        return new Result(2000, "success", list);
    }

    @RequestMapping("/zone/prefecture")
    public Result selectZoneBusiness() {
        List<TbZone> list = tbZoneService.list();
        return new Result(2000, "success", list);
    }

    @Autowired
    private PageContextService pageContextService;

    @RequestMapping("/zoneBusiness/selectZoneBusiness")
    public Result pageContext() {
        Result result = pageContextService.listPage();
        return new Result(2000, "result", result);
    }


    @RequestMapping("/zoneBusiness/selectZoneBusinessAaa")
    public Result All() {
        Result result = pageContextService.All();
        System.out.println("******"+result);
        return new Result(2000, "result", result);
    }
    @RequestMapping("/findGoodsByBid/{bid}")
    public Result findGoodsAByBid(@PathVariable String bid){
        Result goodsAndNumByBid = pageContextService.findGoodsByBid(bid);
        System.out.println("goodsAndNumByBid = " + goodsAndNumByBid);
        return goodsAndNumByBid;
    }

    @RequestMapping("/article/getAllQianArticle/{id}")
    public Result getAllQianArticle(@PathVariable String id){
        Result goodsAndNumByBid = pageContextService.AllArtice(id);
        System.out.println("goodsAndNumByBid = " + goodsAndNumByBid);
        return goodsAndNumByBid;
    }





    @RequestMapping("/findGoodsAndNumByBid/{bid}")
    public Result findGoodsAndNumByBid(@PathVariable String bid) {
        System.out.println("bid = " + bid);
        return goodsFeigen.findGoodsAndNumByBid(bid);
    }

    @RequestMapping("/bottomArticle/getQianAllBottomArticle")
    public Result Title() {
        Result title = TbBottomArticleService.Title();
        return new Result(2000, "Title", title);
    }
    @RequestMapping("/link/getQianLink")
    public Result Link() {
        List<TbLink> list = tbLinkService.list();
        return new Result(2000, "Link",list);
    }


}
